import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";

type Search = {
  name: string,
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

type data = {
  id?: number;
  name: string;
  code: string;
  status: number;
}

// 仓门列表
export const doorList = (params?: Search) => {
  return http.request<Result>("get", "/api/door/List", { params });
};

// 新增仓门
export const addDoor = (data?: data) => {
  return http.request<Result>("post", "/api/door/Add", { data });
};

// 修改仓门
export const updateDoor = (data?: data) => {
  return http.request<Result>("post", "/api/door/Update", { data });
};

// 删除仓门
export const delDoor = (id: number) => {
  return http.request<Result>("post", `/api/door/Delete/${id}`, {});
};

// 仓门类型
export const DoorType = () => {
  return http.request<arrayResult>("get", `/api/Dict/ListByParentCode/DoorType`, {});
};

// 仓门下拉
export const GetAllDoor = (data: any) => {
  return http.request<arrayResult>("get", `/api/door/GetAllDoor`, { params: data });
};

// 仓门开关
export const isDoor = (params: any) => {
  return http.request<Result>("post", `/api/door/Door`, { params });
};
